<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: colorpicker  YAHOO.util.Color   (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">

	<div id="hd">
        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
        <h3>colorpicker&nbsp; <span class="subtitle">2.6.0</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_colorpicker.html">colorpicker</a>
                 &gt; YAHOO.util.Color 
                
            </p>


	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form name="yui-classopts-form">
    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
    <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
            </form>

                    <h2>
                        

                        
                        
                            Class <b>YAHOO.util.Color</b>
                        <span class="extends">
                        </span>

                        <span class="extends">
                        </span>
                        
                        </code>
                    </h2>
                    <!-- class tree goes here -->
                    
                
  

                    <div class="summary description">
                        Provides color conversion and validation utils
                    </div>




                        <div class="section method details">
                            <h3 id="methods">Methods</h3>
                            <div class="content">
                                    <div class="private">
                                    <h4>
                                        <a name="method__createHostElement">_createHostElement</a></h4>
                                    <div class="detail">
                                        <code>
                                         private 
                                        
                                        
                                        void
                                            <strong>_createHostElement</strong>
                                           (
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Creates the host element if it doesn't exist
                                        </div>

                                        <div class="description">


                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        void
                                                    </code></dt>
                                                    <dd></dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_dec2hex">dec2hex</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        string
                                            <strong>dec2hex</strong>
                                           (
                                                
                                                        
                                                         n
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts an int 0...255 to hex pair 00...FF
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>n &lt;int&gt;</code>
                                                              the number to convert
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        string
                                                    </code></dt>
                                                    <dd>the hex equivalent</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_hex2dec">hex2dec</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        int
                                            <strong>hex2dec</strong>
                                           (
                                                
                                                        
                                                         str
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts a hex pair 00...FF to an int 0...255
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>str &lt;string&gt;</code>
                                                              the hex pair to convert
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        int
                                                    </code></dt>
                                                    <dd>the decimal</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_hex2rgb">hex2rgb</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        [int, int, int]
                                            <strong>hex2rgb</strong>
                                           (
                                                
                                                        
                                                         str
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts a hex string to rgb
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>str &lt;string&gt;</code>
                                                              the hex string
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        [int, int, int]
                                                    </code></dt>
                                                    <dd>an array containing the rgb values</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_hsv2rgb">hsv2rgb</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        [int, int, int]
                                            <strong>hsv2rgb</strong>
                                           (
                                                
                                                        
                                                         h
                                                    
                                                
                                                        , 
                                                         s
                                                    
                                                
                                                        , 
                                                         v
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts HSV (h[0-360], s[0-1]), v[0-1] to RGB [255,255,255]
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>h &lt;int|[int, float, float]&gt;</code>
                                                              the hue, or an
array containing all three parameters
                                                        </dd>
                                                        <dd>
                                                            <code>s &lt;float&gt;</code>
                                                              the saturation
                                                        </dd>
                                                        <dd>
                                                            <code>v &lt;float&gt;</code>
                                                              the value/brightness
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        [int, int, int]
                                                    </code></dt>
                                                    <dd>the red, green, blue values in
decimal.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_real2dec">real2dec</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        int
                                            <strong>real2dec</strong>
                                           (
                                                
                                                        
                                                         n
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts 0-1 to 0-255
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>n &lt;float&gt;</code>
                                                              the number to convert
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        int
                                                    </code></dt>
                                                    <dd>a number 0-255</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_rgb2hex">rgb2hex</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        string
                                            <strong>rgb2hex</strong>
                                           (
                                                
                                                        
                                                         r
                                                    
                                                
                                                        , 
                                                         g
                                                    
                                                
                                                        , 
                                                         b
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts decimal rgb values into a hex string
255,255,255 -> FFFFFF
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>r &lt;int|[int, int, int]&gt;</code>
                                                              the red value, or an
array containing all three parameters
                                                        </dd>
                                                        <dd>
                                                            <code>g &lt;int&gt;</code>
                                                              the green value
                                                        </dd>
                                                        <dd>
                                                            <code>b &lt;int&gt;</code>
                                                              the blue value
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        string
                                                    </code></dt>
                                                    <dd>the hex string</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_rgb2hsv">rgb2hsv</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        [int, float, float]
                                            <strong>rgb2hsv</strong>
                                           (
                                                
                                                        
                                                         r
                                                    
                                                
                                                        , 
                                                         g
                                                    
                                                
                                                        , 
                                                         b
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Converts to RGB [255,255,255] to HSV (h[0-360], s[0-1]), v[0-1]
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>r &lt;int|[int, int, int]&gt;</code>
                                                              the red value, or an
array containing all three parameters
                                                        </dd>
                                                        <dd>
                                                            <code>g &lt;int&gt;</code>
                                                              the green value
                                                        </dd>
                                                        <dd>
                                                            <code>b &lt;int&gt;</code>
                                                              the blue value
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        [int, float, float]
                                                    </code></dt>
                                                    <dd>the value converted to hsv</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_websafe">websafe</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                        
                                        
                                        [int, int, int]
                                            <strong>websafe</strong>
                                           (
                                                
                                                        
                                                         r
                                                    
                                                
                                                        , 
                                                         g
                                                    
                                                
                                                        , 
                                                         b
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Returns the closest websafe color to the supplied rgb value.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>r &lt;int|[int, int, int]&gt;</code>
                                                              the red value, or an
array containing all three parameters
                                                        </dd>
                                                        <dd>
                                                            <code>g &lt;int&gt;</code>
                                                              the green value
                                                        </dd>
                                                        <dd>
                                                            <code>b &lt;int&gt;</code>
                                                              the blue value
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        [int, int, int]
                                                    </code></dt>
                                                    <dd>an array containing the closes
websafe rgb colors.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                            </div>
                        </div>







			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_carousel.html">carousel</a></li>

                                <li class=""><a href="module_charts.html">charts</a></li>

                                <li class="selected"><a href="module_colorpicker.html">colorpicker</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_cookie.html">cookie</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_editor.html">editor</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_get.html">get</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_imagecropper.html">imagecropper</a></li>

                                <li class=""><a href="module_imageloader.html">imageloader</a></li>

                                <li class=""><a href="module_json.html">json</a></li>

                                <li class=""><a href="module_layout.html">layout</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_paginator.html">paginator</a></li>

                                <li class=""><a href="module_profiler.html">profiler</a></li>

                                <li class=""><a href="module_profilerviewer.html">profilerviewer</a></li>

                                <li class=""><a href="module_resize.html">resize</a></li>

                                <li class=""><a href="module_selector.html">selector</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_uploader.html">uploader</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>

                                <li class=""><a href="module_yuiloader.html">yuiloader</a></li>

                                <li class=""><a href="module_yuitest.html">yuitest</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class="selected"><a href="YAHOO.util.Color.html">YAHOO.util.Color</a></li>
                                <li class=""><a href="YAHOO.widget.ColorPicker.html">YAHOO.widget.ColorPicker</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="Color.js.html">Color.js</a></li>
                                <li class=""><a href="ColorPicker.js.html">ColorPicker.js</a></li>
                        </ul>
                    </div>


                    <div class="module">
                        <h4>Methods</h4>
                        <ul class="content">        
                                <li class="private"><!--<code>void</code>-->
                                <a href="#method__createHostElement">_createHostElement</a>
                                </li>
                                <li class=""><!--<code>string</code>-->
                                <a href="#method_dec2hex">dec2hex</a>
                                </li>
                                <li class=""><!--<code>int</code>-->
                                <a href="#method_hex2dec">hex2dec</a>
                                </li>
                                <li class=""><!--<code>[int, int, int]</code>-->
                                <a href="#method_hex2rgb">hex2rgb</a>
                                </li>
                                <li class=""><!--<code>[int, int, int]</code>-->
                                <a href="#method_hsv2rgb">hsv2rgb</a>
                                </li>
                                <li class=""><!--<code>int</code>-->
                                <a href="#method_real2dec">real2dec</a>
                                </li>
                                <li class=""><!--<code>string</code>-->
                                <a href="#method_rgb2hex">rgb2hex</a>
                                </li>
                                <li class=""><!--<code>[int, float, float]</code>-->
                                <a href="#method_rgb2hsv">rgb2hsv</a>
                                </li>
                                <li class=""><!--<code>[int, int, int]</code>-->
                                <a href="#method_websafe">websafe</a>
                                </li>
                        </ul>
                    </div>



            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
